// The Vue build version to load with the `import` command
// (runtime-only or standalone) has been set in webpack.base.conf with an alias.
import Vue from 'vue'
import App from './App'
import router from './router'
Vue.config.productionTip = false
//import "babel-polyfill"
//后台请求数据
import qs from 'qs'
import axios from 'axios'

// axios 配置
axios.defaults.timeout = 5000;
//axios.defaults.headers.post['Content-Type'] = 'application/x-www-form-urlencoded';
Vue.prototype.$http = axios //ajax
Vue.prototype.$http.defaults.headers.post['Content-Type'] = 'application/x-www-form-urlencoded'
Vue.prototype.$http.defaults.withCredentials = true
// POST传参序列化(添加请求拦截器)
Vue.prototype.$http.interceptors.request.use((config) => {
  // 发送请求之前做某件事
  if (config.method === 'post') {
    config.data = qs.stringify(config.data)
  }
  return config
}, (error) => {
  return error
})
//下面是layer弹窗
import layer from 'vue-layer'
Vue.prototype.$layer = layer(Vue, {
  msgtime: 3, //目前只有一项，即msg方法的默认消失时间，单位：秒
});
//下面是vuex

import Vuex from 'vuex'
Vue.use(Vuex);
const store = new Vuex.Store({
  state: {
    count: ""
  },
  mutations: {

    //  sonsay (state, index) {
    //    state.count = index
    //    console.log(state.count)//打印改变过后的值
    //  }
    // sonsay (state) {
    //     state.count +=1
    //     console.log(state.count)//打印改变过后的值
    //  },

    //  sonsay (state) {
    //     state.count +=1
    //     console.log(state.count)//打印改变过后的值
    //   }
  }
})
/* eslint-disable no-new */
new Vue({
  el: '#app',
  router,
  store,
  components: {
    App
  },
  template: '<App/>'
});
